package com.ruoyi.bizsys.service.impl;

import java.util.List;
import java.util.Arrays;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                import com.ruoyi.common.utils.DateUtils;
            import org.springframework.stereotype.Service;
    import com.ruoyi.bizsys.mapper.ExtTransferResultMapper;
import com.ruoyi.bizsys.domain.ExtTransferResult;
import com.ruoyi.bizsys.service.IExtTransferResultService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


/**
 * 交易数据Service业务层处理
 *
 * @author african-loan
 * @date 2021-12-30
 */
@Service
public class ExtTransferResultServiceImpl extends ServiceImpl<ExtTransferResultMapper,ExtTransferResult> implements IExtTransferResultService {

    /**
     * 查询交易数据
     *
     * @param id 交易数据ID
     * @return 交易数据
     */
    @Override
    public ExtTransferResult selectExtTransferResultById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询交易数据列表
     *
     * @param extTransferResult 交易数据
     * @return 交易数据
     */
    @Override
    public List<ExtTransferResult> selectExtTransferResultList(ExtTransferResult extTransferResult) {
        if(extTransferResult.getParams().entrySet().size() > 0){
            return this.list(new QueryWrapper<>(extTransferResult).ge("create_time",extTransferResult.getParams().get("beginTime")).lt("create_time",extTransferResult.getParams().get("endTime")).last("order by id desc"));
        }
        return this.list(new QueryWrapper<>(extTransferResult).last("order by id desc"));
    }

    /**
     * 新增交易数据
     *
     * @param extTransferResult 交易数据
     * @return 结果
     */
            @Override
    public int insertExtTransferResult(ExtTransferResult extTransferResult) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        extTransferResult.setCreateTime(DateUtils.getNowDate());
                                                                    return baseMapper.insert(extTransferResult);
    }

    /**
     * 修改交易数据
     *
     * @param extTransferResult 交易数据
     * @return 结果
     */
            @Override
    public int updateExtTransferResult(ExtTransferResult extTransferResult) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                extTransferResult.setUpdateTime(DateUtils.getNowDate());
                            return baseMapper.updateById(extTransferResult);
    }

    /**
     * 批量删除交易数据
     *
     * @param ids 需要删除的交易数据ID
     * @return 结果
     */
            @Override
    public int deleteExtTransferResultByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除交易数据信息
     *
     * @param id 交易数据ID
     * @return 结果
     */
    @Override
    public int deleteExtTransferResultById(Long id) {
        return baseMapper.deleteById(id);
    }

}
